package sliceformUtils;

import pluginUtils.Pos3D;

// Un segment, c'est deux sommets
public class Segment extends Encombrant implements Rotable<Segment>{
	
	protected Pos3D S1,S2; 
	
	
	public Segment(Pos3D a,Pos3D b){
		S1=a; 
		S2=b; 
		if(S1.getX()<S2.getX()){minX=S1.getX(); maxX=S2.getX();} else {minX=S2.getX(); maxX=S1.getX(); } 
		if(S1.getY()<S2.getY()){minY=S1.getY(); maxY=S2.getY();} else {minY=S2.getY(); maxY=S1.getY(); } 
		if(S1.getZ()<S2.getZ()){minZ=S1.getZ(); maxZ=S2.getZ();} else {minZ=S2.getZ(); maxZ=S1.getZ(); } 
		xwide=maxX-minX; 
		ywide=maxY-minY; 
		zwide=maxZ-minZ;
	}

	public Pos3D getOne(){return S1; }
	public Pos3D getTwo(){return S2; }
	
	public String toString(){
		String s="Segment \n"; 
		s+=S1+"\n"+S2; 
		return s; 
	}

	@Override
	public Segment rotate(CoupleDAngles cda) {
		return new Segment(getOne().rotate(cda),getTwo().rotate(cda)); 
	}

	@Override
	public Segment rotateInverse(CoupleDAngles cda) {
		return new Segment(getOne().rotateInverse(cda),getTwo().rotateInverse(cda)); 
	}
	
	
	
}
